crw<-function(n, base.mu, base.sd, h){
  init<-base.mu
  tser<-init
  for(ii in 1:n){
    print(ii)
    tser<-c(tser, h*tser[ii-1]+(1-h)*rnorm(n=1, mean=base.mu, sd=base.sd))
  }
  plot(tser, type="l")
  tser
}

a<-crw(1000, 0, 1, 0)
apos<-crw(1000, 0, 1, 0.9)
aneg<-crw(1000, 0, 1, -0.9)

rwbias<-function(n, env.mu, env.sd, opt.mu, w){ #w is effort
  init<-env.mu
  tser<-init
  for(ii in 1:n){
    print(ii)
    tser<-c(tser, (1-w)*rnorm(n=1, mean=env.mu, sd=env.sd)+w*opt.mu)#rnorm(n=1, mean=bias.mu, sd=0.1*base.sd))
  }
  plot(tser, type="l")
  tser
}

a<-rwbias(1000, 0, 1, 1, 0)
b<-rwbias(1000, 0, 1, 1, 0.5)
c<-rwbias(1000, 0, 1, 1, 0.9)
summary(data.frame(a, b, c))